package pl.edu.pw.perg.compinfodb.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.transaction.annotation.Transactional;

import pl.edu.pw.perg.compinfodb.entities.HistoryItem;

public class HistoryDAO extends GenericSpringDAO<HistoryItem> implements IHistoryDao {

	/* (non-Javadoc)
	 * @see pl.edu.pw.perg.compinfodb.dao.IHistoryDao#findElementHistory(java.lang.Long)
	 */
	@Transactional
	public List<HistoryItem> findElementHistory(Long elementId){
		Session s = getSession();
		List<HistoryItem> lst = findByCriteria(Restrictions.eq("peId", elementId));
//		s.close();
		return lst;
	    
	}
	@Override
	public void deleteAll() {
		Query q = getSession().createQuery("delete from HistoryItem");
		q.executeUpdate();
	}
}
